import { CheckCircleOutlined, ExclamationCircleOutlined } from "@ant-design/icons";
import moment from "moment";
import { formatterCurrency, formatterCurrencyStr, formatterSize, formatterSizeFromMB } from "@utils/format";
import copy from "copy-to-clipboard";
import common from "@utils/common";

const extrinsics = [
	{
		title: "Time(" + common.getTimeZone() + ")",
		dataIndex: "timestamp",
		key: "timestamp",
		width: "15%",
		showType: "datetime",
		tpl: "fromNow"
	},
	{
		title: "Hash",
		dataIndex: "extrinsic_hash",
		key: "extrinsic_hash",
		width: "22%",
		textWrap: "word-break",
		ellipsis: true,
		showType: "addr",
		isLong: true,
		link: "/extrinsic/{extrinsic_hash}"
	},
	{
		title: "Block",
		dataIndex: "block_id",
		key: "block_id",
		width: "10%",
		textWrap: "word-break",
		ellipsis: true,
		showType: "link",
		tpl: "/block/{block_id}",
	},
	{
		title: "Events",
		dataIndex: "events_num",
		key: "events_num",
		width: "10%",
		textWrap: "word-break",
		showType: "link",
		tpl: "/extrinsic/{extrinsic_hash_s}"
	},
	{
		title: "Method",
		dataIndex: "extrinsic_name",
		key: "extrinsic_name",
		width: "22%",
		textWrap: "word-break",
	},
	{
		title: "Result",
		dataIndex: "result",
		width: "10%",
		render: (text, record, index) => {
			return record.result ? (
				<span className="green">
					<CheckCircleOutlined /> Success
				</span>
			) : (
				<span className="red">
					<ExclamationCircleOutlined /> Failed
				</span>
			);
		}
	},
];
const transfer = [
	{
		title: "Time(" + common.getTimeZone() + ")",
		dataIndex: "timestamp",
		key: "timestamp",
		width: "8%",
		showType: "datetime",
		tpl: "fromNow"
	},
	{
		title: "Hash",
		dataIndex: "extrinsic_hash",
		key: "extrinsic_hash",
		width: "18%",
		textWrap: "word-break",
		ellipsis: true,
		showType: "addr",
		link: "/extrinsic/{extrinsic_hash}"
	},
	{
		title: "Block",
		dataIndex: "block_id",
		key: "block_id",
		width: "8%",
		textWrap: "word-break",
		ellipsis: true,
		showType: "link",
		tpl: "/block/{block_id}",
	},
	{
		title: "From",
		dataIndex: "from",
		key: "from",
		width: "18%",
		textWrap: "word-break",
		ellipsis: true,
		showType: "addr",
		link: "/account/{from}"
	},
	{
		title: "To",
		dataIndex: "to",
		key: "to",
		width: "18%",
		textWrap: "word-break",
		ellipsis: true,
		showType: "addr",
		link: "/account/{to}"
	},
	{
		title: "Amount",
		dataIndex: "amount",
		key: "amount",
		width: "10%",
		textWrap: "word-break",
		ellipsis: true,
		showType: "balance-logo"
	},
	{
		title: "Result",
		dataIndex: "result",
		width: "10%",
		render: (text, record, index) => {
			return record.result ? (
				<span className="green">
					<CheckCircleOutlined /> Success
				</span>
			) : (
				<span className="red">
					<ExclamationCircleOutlined /> Failed
				</span>
			);
		}
	},
];
const challenge = [
	{
		title: "Time(" + common.getTimeZone() + ")",
		dataIndex: "timestamp",
		key: "timestamp",
		width: "15%",
		showType: "datetime",
		tpl: "fromNow"
	},
	{
		title: "Block",
		dataIndex: "start",
		key: "start",
		width: "15%",
		showType: "link",
		tpl: "/block/{start}",
	},
	{
		title: "Progress",
		dataIndex: "progress",
		key: "progress",
		width: "40%",
		textWrap: "word-break",
		// render: (text, record, index) => {
		// 	return (<div className="challenge-progress">
		// 		<div className="pro">
		// 			<span>Service Files</span>
		// 			<i></i>
		// 			<div>
		// 				<font className={record.submit_service && record.submit_service_result ? 'pass' : record.submit_service ? 'fail' : ''}></font>
		// 				<label>Submit</label>
		// 			</div>
		// 			<i></i>
		// 			<div>
		// 				<font className={record.service_result ? 'pass' : record.submit_service ? 'fail' : 'pending'}></font>
		// 				<label>Verify</label>
		// 			</div>
		// 		</div>
		// 		<div className="pro">
		// 			<span>Idle Files&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
		// 			<i></i>
		// 			<div>
		// 				<font className={record.submit_idle && record.submit_idle_result ? 'pass' : record.submit_idle ? 'fail' : ''}></font>
		// 				<label>Submit</label>
		// 			</div>
		// 			<i></i>
		// 			<div>
		// 				<font className={record.idle_result ? 'pass' : record.submit_idle ? 'fail' : 'pending'}></font>
		// 				<label>Verify</label>
		// 			</div>
		// 		</div>
		// 	</div>)
		// },
		render: (text, record, index) => {
			return (<div className="challenge-progress">
				<div className="pro">
					<span>Service Files</span>
					<i></i>
					<div>
						<font className={record.submit_service ? 'pass' : 'fail'}></font>
						<label>Submit</label>
					</div>
					<i></i>
					<div>
						<font className={!record.submit_service ? "" : record.submit_service_result && record.service_result ? 'pass' : record.status == "Failed" || record.submit_service_result ? 'fail' : 'pending'}></font>
						<label>Verify</label>
					</div>
				</div>
				<div className="pro">
					<span>Idle Files&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
					<i></i>
					<div>
						<font className={record.submit_idle ? 'pass' : 'fail'}></font>
						<label>Submit</label>
					</div>
					<i></i>
					<div>
						<font className={!record.submit_idle ? "" : record.submit_idle_result && record.idle_result ? 'pass' : record.status == "Failed" || record.submit_idle_result ? 'fail' : 'pending'}></font>
						<label>Verify</label>
					</div>
				</div>
			</div>)
		}
	},
	{
		title: "Status",
		dataIndex: "status",
		key: "status",
		width: "15%",
		textWrap: "word-break",
	},
	{
		title: "Result",
		dataIndex: "result",
		key: "result",
		width: "15%",
		textWrap: "word-break",
		showType: "balance-logo2"
	},
];
const consensu = [
	{
		title: "Time(" + common.getTimeZone() + ")",
		dataIndex: "timestamp",
		key: "timestamp",
		width: "20%",
		showType: "datetime",
		tpl: "fromNow"
	},
	{
		title: "Era",
		dataIndex: "era_id",
		key: "era_id",
		width: "20%",
		textWrap: "word-break",
	},
	{
		title: "Status",
		dataIndex: "status",
		key: "status",
		width: "20%",
	},
	{
		title: "Reward",
		dataIndex: "available_reward",
		key: "available_reward",
		width: "20%",
		showType: "balance-logo2"
	},
	{
		title: "Punishment",
		dataIndex: "punishment",
		key: "punishment",
		width: "20%",
		showType: "balance-logo2"
	}
];
export default {
	transfer,
	extrinsics,
	challenge,
	consensu
};
